/*
 * Yabumi, a 2d scrolling shoot-em-up game.
 * Copyright (C) 2003 Gemma Teruaki <terugen@yabumi.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
 */

#ifndef _ENEMY_H_
#define _ENEMY_H_

/* includes begin */ 
#ifndef _TASKMANAGER_H_
/* need ONETIME_COUNT task _option _tasklist*/
#include "../taskmanager.h"
#endif
#ifndef _HITCIRCLE_H_
/* need _was_hit, _weapon */
#include "hitcircle.h"
#endif
/* need SDL_Surface */
#include <SDL.h>
/* need bool */
#include <stdbool.h>
/* includes end */

/* constants begin */
#define ENEMY_MAX_SPEED (1600)
#define ENEMY_ROTATE_SPEED (1)
#define ENEMY_SHIELD (10)
#define ENEMY_FIRE_MISSILE_WAIT (ONETIME_COUNT + 7)
#define ENEMY_FIRE_FLAME_WAIT (ONETIME_COUNT + 15)
/* NOTE that TASK_ENEMY_THRUST can be tasked multiply.*/
/* NOTE that TASK_ENEMY_ROTATE can be tasked multiply.*/
/* WARNING TASK_ENEMY_ADD accel[] init depends on this value. WARNING */
#define ENEMY_THRUST_TIME (ONETIME_COUNT + 25)
#define ENEMY_THRUST_WAIT (ONETIME_COUNT + 10)
#define ENEMY_ROTATE_TIME (ONETIME_COUNT + 5)
#define ENEMY_KILL_TIME (ONETIME_COUNT + 25)
/* constants end */

/* typedef begin */
typedef struct {
  bool fire;
  bool thrust;
  bool rotate_left;
  bool rotate_right;
  bool fox1;
  _was_hit was_hit;
} _enemy_tasks;

typedef struct {
  bool fire;
  bool thrust;
} _enemy_waits;

typedef struct {
  int x, y;
  int dx, dy;
  int angle;
  int accel[ENEMY_THRUST_TIME];
  int shield;
  _weapon weapon;
  _enemy_tasks tasks;
  _enemy_waits waits;
  /* _list_item *root; !!!circular reference!!! */
  void *root;
} _Enemy;
/* typedef end */

/* Global Objects */
extern SDL_Surface *Sprite_Enemy[3][360];
extern SDL_Surface *Sprite_Enemy_Thrust[5][360];
/* !!!circular reference!!! */
/* extern _list_header player_list_header; */

/* Prototypes from the enemy.c file. */
void Enemy_Init();
void Enemy_Free();
_Enemy *Enemy_Create(int x, int y, int dx, int dy, int angle);
task Enemy_Add(_option *optv);
task Enemy_Move(_option *optv);
task Enemy_Draw(_option *optv);
task Enemy_Fire(_option *optv);
task Enemy_Fire_Missile(_option *optv);
task Enemy_Fire_Flame(_option *optv);
task Enemy_Rotate_Left(_option *optv);
task Enemy_Rotate_Right(_option *optv);
task Enemy_Thrust(_option *optv);
task Enemy_was_Hit(_option *optv);
task Enemy_was_Hit_by_Missile(_option *optv);
task Enemy_was_Hit_by_Flame(_option *optv);
task Enemy_was_Hit_by_Homing(_option *optv);
task Enemy_was_Hit_by_Item_Missile(_option *optv);
task Enemy_was_Hit_by_Item_Flame(_option *optv);
task Enemy_Kill(_option *optv);
#endif
